package com.rtp.transformer.parser.model;

import java.util.List;

import com.rtp.transformer.parser.convert.IConverter;



/**
 * The pattern to fill with field node in husband config file
 * include FormatCus list when the class has son class
 * @author xueming
 *
 */
public class FormatField {

	private String pattern;
	private String fieldname;
	private Integer fieldlength=new Integer(0);
	private List<FormatCus> childNode;
	private IConverter converter;
	
	public IConverter getConverter() {
		return converter;
	}
	public void setConverter(IConverter converter) {
		this.converter = converter;
	}
	public boolean isBlank(){
		return fieldname==null;
	}
	public boolean isLeafNode() {
		return childNode==null;
	}
	
	public FormatField(String fieldname,Integer fieldlength,List<FormatCus> childNode,String pattern,String converter) {
		this.fieldname = fieldname;
		this.fieldlength = fieldlength;
		this.childNode = childNode;
		this.pattern = pattern;
		if(converter!=null)
			try {
				this.converter = (IConverter) Class.forName(converter).newInstance();
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}
	
	public Integer getFieldlength() {
		return fieldlength;
	}
	
	public void setFieldlength(Integer fieldlength) {
		this.fieldlength = fieldlength;
	}
	
	public String getFieldname() {
		return fieldname;
	}
	
	public void setFieldname(String fieldname) {
		this.fieldname = fieldname;
	}

	public List<FormatCus> getChildNode() {
		return childNode;
	}

	public String getPattern() {
		return pattern;
	}

	public void setPattern(String pattern) {
		this.pattern = pattern;
	}

}
